﻿using System.Collections.Generic;
using System.Linq;

namespace VPLink2014.Data.MesApplis
{
	public static class VOApplicationMapper
	{
		public static VOApplication ConvertToApplication( Application appli, AppliDirection appliDirDb )
		{
			return new VOApplication()
			{
				Id = appli.id,
				Name = appli.titre,
				Url = appli.url,
				Description = appli.description,
				Categorie = string.IsNullOrEmpty( appli.categorie ) ? "Autre" : appli.categorie,
				Rang = appliDirDb.rang,
				Obligatoire = appliDirDb.obligatoire
			};
		}

		public static VOApplication ConvertToApplication( Application appli, AppliDept appliDeptDb )
		{
			return new VOApplication()
			{
				Id = appli.id,
				Name = appli.titre,
				Url = appli.url,
				Description = appli.description,
				Categorie = string.IsNullOrEmpty( appli.categorie ) ? "Autre" : appli.categorie,
				Rang = appliDeptDb.rang,
				Obligatoire = appliDeptDb.obligatoire
			};
		}

		public static VOApplication ConvertToApplication( Application appli, AppliService appliSceDb )
		{
			return new VOApplication()
			{
				Id = appli.id,
				Name = appli.titre,
				Url = appli.url,
				Description = appli.description,
				Categorie = string.IsNullOrEmpty( appli.categorie ) ? "Autre" : appli.categorie,
				Rang = appliSceDb.rang,
				Obligatoire = appliSceDb.obligatoire
			};
		}

		public static VOApplication ConvertToApplication( Application appli, AppliUser appliUserDb )
		{
			return new VOApplication()
			{
				Id = appli.id,
				Name = appli.titre,
				Description = appli.description,
				Rang = appliUserDb.rang,
				Obligatoire = appliUserDb.obligatoire,
				Categorie = string.IsNullOrEmpty( appli.categorie ) ? "Autre" : appli.categorie,
				Url = appli.url
			};
		}

		public static VOApplication ConvertToApplication( Application appli )
		{
			return new VOApplication()
			{
				Id = appli.id,
				Name = appli.titre,
				Url = appli.url,
				Description = appli.description,
				Categorie = string.IsNullOrEmpty( appli.categorie ) ? "Autre" : appli.categorie,
			};
		}
	}
}
